function [data] = aggregateCtsTimeData_providerAdoptions(data)	
	spell2period = data.spell2period;
	
	% Read dimensions
	K         = data.dims.dims1{3};
	NumSpells = length(spell2period);
	T         = double(max(spell2period));
	
	% Match each day tt to index of earliest spell of that day
	period2firstSpell = accumarray(spell2period, [1:NumSpells]', [T 1], @min); % T x 1
	% (for each day tt: this vector gives index of spell that starts at the start of day tt)
	
	%%% Simplify the data to make it at the day level (not spell level)
	data.dims.NumObs   = T*K;
	data.dims.dims1{1} = T*K;
	data.dims.dims1{2} = T;

	% T-K part
	myX     = data.Xparts{1}.X;     % (NumSpells*K) x NumX
	myX_FEs = data.Xparts{1}.X_FEs; % (NumSpells*K) x NumX_FEs
	
	myX     = reshape(myX,     [NumSpells K size(myX, 2)]);     % NumSpells x K x NumX
	myX_FEs = reshape(myX_FEs, [NumSpells K size(myX_FEs, 2)]); % NumSpells x K x NumX_FEs
	
	myX     = myX(period2firstSpell,:,:); % T x K x NumX
	myX_FEs = myX_FEs(period2firstSpell,:,:); % T x K x NumX_FEs
	
	myX     = reshape(myX,     [T*K size(myX, 3)]);     % (T*K) x NumX
	myX_FEs = reshape(myX_FEs, [T*K size(myX_FEs, 3)]); % (T*K) x NumX_FEs
	
	data.Xparts{1}.X = myX;
	data.Xparts{1}.X_FEs = myX_FEs;
	clear myX;

	% T part
	data.Xparts{2}.X     = data.Xparts{2}.X(period2firstSpell,:);     % T x NumX
	data.Xparts{2}.X_FEs = data.Xparts{2}.X_FEs(period2firstSpell,:); % T x NumX_FEs
	
	% Aggregate Y (take sum across spells of that day tt)
	M = sparse(T, NumSpells);
	ind = sub2ind([T NumSpells], spell2period, [1:NumSpells]');
	M(ind) = 1;
	data.Y = reshape(data.Y, [NumSpells K]);
	data.Y = M * data.Y;
	data.Y = data.Y(:); % (T*K) x 1

	data.logLambdaOffset = reshape(data.logLambdaOffset, [NumSpells K]);
	data.logLambdaOffset = data.logLambdaOffset(period2firstSpell,:); % T x K
	data.logLambdaOffset = reshape(data.logLambdaOffset, [T*K 1]); % (T*K) x 1
	
	data = rmfield(data, 'spell2period');
	data = rmfield(data, 'spellDurations');
	
	myidxes = find(data.Y(:)>0);
	data.LL_offset = -sum(gammaln(1+data.Y(myidxes)));
end
